package mapengine.effects
{
	import flash.display.DisplayObject;
	
	import isoengine.interfaces.IIsoWorld;
	
	import values.map.MapObjectValue;
	
	import view.component.effects.BattleSkillView;
	import view.component.effects.BattleTextFieldView;

	public class EffectFactory
	{
		public static function createEffect(asset:IEffectAsset , x:int , y:int , isoWorld:IIsoWorld , classRef:Class = null ,params:* = null):EffectObjectBase
		{
			var objData:MapObjectValue = new MapObjectValue();
			objData.x = x;
			objData.y = y;
			objData.width = 1;
			objData.height = 1;
			objData.walkable = true;
			classRef =  (classRef == null ? EffectObjectBase : classRef);
			var effObj:EffectObjectBase = new classRef() as EffectObjectBase;
			effObj.asset.addChild(asset as DisplayObject);
			effObj.objectData = objData;
			effObj.params = params;
			isoWorld.addSprite(effObj , false , null , true);
			asset.effectObj = effObj;
			effObj.assetEffect = asset;
			effObj.start();
			return effObj;
		}
		
		public static function createSkillEffect(skillName:String , path:String , demoClassRef:String , x:int , y:int , isoWorld:IIsoWorld , assetClass:Class = null , classRef:Class = null , params:* = null):EffectObjectBase
		{
			assetClass = (assetClass == null ? BattleSkillView : assetClass);
			var asset:BattleSkillView = new assetClass() as BattleSkillView;
			asset.initlize(path , demoClassRef);
			asset.text = skillName;
			return createEffect(asset , x, y , isoWorld , classRef == null ? SkillEffect : classRef , params);
		}
		
		public static function createTextEffect(textStr:String , x:int , y:int , isoWorld:IIsoWorld , assetClass:Class = null ,classRef:Class = null , params:* = null):EffectObjectBase
		{
			assetClass = (assetClass == null ? BattleTextFieldView : assetClass);
			var asset:BattleTextFieldView = new assetClass() as BattleTextFieldView;
			asset.text = textStr;
			return createEffect(asset , x , y , isoWorld , classRef == null ? TweenTextFiledEffect : classRef , params);
		}
	}
}